//2009/08/20 19:00:27
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class EscapeFromRectangle
{
public:
    int shortest(int x, int y, int w, int h)
    {
		int xmin = min(x, abs(w-x));
		int ymin = min(y, abs(h-y));
		return min(xmin, ymin);
    }
};
